function out = arrangeNeurons(in,plotOn)
if ~exist('plotOn','var')||isempty(plotOn)
    plotOn = false;
end

if ~isfield(in,'N')||isempty(in.N)
    N = 100;
else
    N = in.N;
end
cenXY = nan(N,2);

if ~isfield(in,'rNeuron')||isempty(in.rNeuron)
    rNeuron = 3;
else
    rNeuron = in.rNeuron;
end

if ~isfield(in,'fov')||isempty(in.fov)
    fov.x = [-100 100];
    fov.y = [-100 100];
else
    fov = in.fov;
end


for i = 1:N
    done = false;
    while ~done
        currX = fov.x(1)+rand*(fov.x(2)-fov.x(1));
        currY = fov.y(1)+rand*(fov.y(2)-fov.y(1));
        currMat = cenXY-repmat([currX currY],N,1);
        currMat = (currMat(:,1).^2+currMat(:,2).^2-2*rNeuron^2);
        currMat = currMat(~isnan(currMat));
        if any(currMat<=1)
            % then there is overlap....done remains false
        else
            cenXY(i,:) = [currX currY];
            done = true;
        end
    end
end

if plotOn
    figure;
    axes;
    ellipse(repmat(rNeuron,N,1),repmat(rNeuron,N,1),zeros(N,1),cenXY(:,1),cenXY(:,2),'k');
    axis tight;
end
out.cenXY = cenXY;
end